import 'package:flutter/material.dart';

class ButtonWidget extends StatelessWidget {
  const ButtonWidget({
    Key? key,
    this.text,
    this.width,
    this.height,
    this.radius,
    this.onPress,
  }) : super(key: key);

  final String? text;
  final double? width;
  final double? height;
  final double? radius;
  final void Function()? onPress;

  @override
  Widget build(BuildContext context) {
    return Container(
      width: width ?? double.infinity,
      height: height,
      clipBehavior: Clip.antiAlias, //配置裁切才能使圆角生效
      decoration:
          BoxDecoration(borderRadius: BorderRadius.circular(radius ?? 32)),
      child: ElevatedButton(
        onPressed: onPress,
        style: ButtonStyle(
            elevation: MaterialStateProperty.all(0),
            minimumSize: MaterialStateProperty.all(Size.zero)),
        child: Text(
          text ?? "",
          style: const TextStyle(
              fontSize: 16, fontWeight: FontWeight.w300, color: Colors.white),
        ),
      ),
    );
  }
}
